{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/system_setup/css/style.css">
    <link rel="stylesheet" href="../../static/public_file/css/DepartmentSelection.css">
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }

        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }

        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }

        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }

        .div_clase {
            display: inline-block;
            width: 300px;
            height: 30px;
            line-height: 30px;
            font-size: 14px;
            color: #0b0b0b;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div id="new_issues" style="width: 100%;height: 100%;overflow: auto;background-color: white;">
        <div style="width: 100%;height: 40px;border-bottom: #cccccc solid 1px;text-align: right;padding-right: 2%;">
            <button id="save_but" onclick="save_data()"
                    style="width: 100px;height: 30px;margin-top: 5px;background: #2db7f5;color: white;border: #2db7f5 solid 1px;border-radius: 3px;">
                保&nbsp;&nbsp;存
            </button>
            <button id="summit_but" onclick="SelectReviewer()"
                    style="width: 100px;height: 30px;margin-top: 5px;background-color: #1E90FF;color: white;border: #1E90FF solid 1px;border-radius: 3px;">
                提&nbsp;&nbsp;交
            </button>
        </div>

        <div id="party_committee" style="width: 100%;height: 93%;">
            <div style="width: 100%;height: 100%;overflow: auto;margin-top: 1%;">
                <div style="width: 100%;">
                    <table style="width: 90%;margin-left: 5%;">
                        <tr style="width: 100%;">
                            <td style="width: 100%;height: 35px;line-height: 35px;text-align: center;border: #cfcfcf solid 1px;"
                                colspan="4"><h3 style="color: red;">委员会议题审批表</h3></td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 100%;height: 35px;line-height: 35px;padding-left: 1%;background: #F5F5F5;border: #cfcfcf solid 1px;color: #1E90FF;"
                                colspan="4">基本信息
                            </td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;letter-spacing: 2px;">
                                提&nbsp;交&nbsp;人
                            </td>
                            <td id="apply_user"
                                style="width: 35%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;">{{ obj.apply_user.real_name }}</td>
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;">
                                提&nbsp;交&nbsp;科&nbsp;室
                            </td>
                            <td id="company"
                                style="width: 35%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;">{{ obj.company.name }}</td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;">
                                议题编号
                            </td>
                            <td id="number" colspan="3"
                                style="width: 35%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;"></td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 100%;height: 35px;line-height: 35px;padding-left: 1%;background: #F5F5F5;border: #cfcfcf solid 1px;color: #1E90FF;"
                                colspan="4">申请详情
                            </td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">
                                委员会类型
                            </td>
                            <td style="width: 35%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;">
                                <select name="" id="committee_type" style="width: 100%;height: 100%;border: none;outline: none;">
                                    <option value="0">请选择委员会类型</option>
                                    <option value="1" {% if obj.committee_type == '1' %}selected{% endif %}>医疗类</option>
                                    <option value="2" {% if obj.committee_type == '2' %}selected{% endif %}>非医疗类</option>
                                </select>
                            </td>
                            <td style="width: 12%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;">
                                委员会级别
                            </td>
                            <td style="width: 20%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;">
                                <select name="" id="committee" style="width: 100%;height: 100%;border: none;outline: none;" onchange="choose_committee()">
                                    <option value="0">请选择委员会级别</option>
                                    {% for key,val in committee_dict.items %}
                                        <option value="{{ key }}">{{ key }}</option>
                                    {% endfor %}
                                </select>
                            </td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;letter-spacing: 1.2px;">
                                专&nbsp;&nbsp;&nbsp;家&nbsp;&nbsp;&nbsp;库
                            </td>
                            <td colspan="3"
                                style="width: 85%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;">
                                <select name="" id="expert_database" style="width: 100%;height: 100%;border: none;outline: none;">
                                    <option value="0">请选择专家库</option>
                                    {% for expert in expert_obj %}
                                        <option value="{{ expert.id }}" {% if obj.expert_database.id == expert.id %}selected{% endif %}>{{ expert.name }}</option>
                                    {% endfor %}

                                </select>
                            </td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">议&nbsp;题&nbsp;名&nbsp;称</td>
                            <td colspan="3" id="topic_name" style="width: 85%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;" contenteditable="true">{{ obj.topic_name }}</td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">
                                委员会名称
                            </td>
                            <td colspan="3" style="width: 85%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;">
                                <select name="" id="committee_name" style="width: 100%;height: 100%;border: none;outline: none;" onchange="get_topic_number()">
                                    <option value="0">请选择委员会名称</option>
                                </select>
                            </td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">协&nbsp;办&nbsp;科&nbsp;室</td>
                            <td id="dang_xieban" colspan="3" style="width: 85%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;" onclick="show_office_model()">{{ organizing_department }}</td>
                        </tr>
                        <tr style="width: 100%;">
                            <td style="width: 15%;height: 35px;line-height: 35px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;letter-spacing: 1.2px;">
                                备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注
                            </td>
                            <td id="note" colspan="3" style="width: 85%;height: 35px;line-height: 35px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;" contenteditable="true">{{ obj.note }}</td>
                        </tr>
                    </table>
                </div>
                <div style="width: 100%;">
                    <div onclick="jianshu_show()" style="width: 90%;height: 35px;line-height: 35px;margin-left: 5%;background-color: #F5F5F5;color: #1E90FF;padding-left: 1%;border: #cccccc solid 1px;border-top: none;padding-right: 1%;cursor: pointer;font-size: 16px;">
                        议题简述
                    </div>
                    <div id="yt_js" style="width: 100%;">
                        <script id="editor" type="text/plain" style="width:94.9%;height:300px;margin-left: 5%;outline: none;">
                            {% autoescape off %}
                                {{ topic_description }}
                            {% endautoescape %}
                        </script>
                    </div>
                    <div id="btns"></div>
                </div>
                <div id="zhengceyiju" style="width: 100%;">
                    <div onclick="yiju_show()" style="width: 90%;height: 35px;line-height: 35px;margin-left: 5%;background-color: #F5F5F5;color: #1E90FF;padding-left: 1%;border: #cccccc solid 1px;border-top: none;padding-right: 1%;cursor: pointer;font-size: 16px;">
                        政策依据
                    </div>
                    <div id="yt_yj" style="width: 100%;">
                        <script id="editor1" type="text/plain" style="width:94.9%;height:300px;margin-left: 5%;outline: none;">
                            {% autoescape off %}
                                {{ policy_basis }}
                            {% endautoescape %}
                        </script>
                    </div>
                    <div id="btns1"></div>
                </div>
                <div id="jiejuefangan" style="width: 100%;">
                    <div onclick="jiejuefangan_show()" style="width: 90%;height: 35px;line-height: 35px;margin-left: 5%;background-color: #F5F5F5;color: #1E90FF;padding-left: 1%;border: #cccccc solid 1px;border-top: none;padding-right: 1%;cursor: pointer;font-size: 16px;">
                        拟供选择方案
                    </div>
                    <div id="jj_fa_yj" style="width: 100%;">
                        <script id="editor2" type="text/plain" style="width:94.9%;height:300px;margin-left: 5%;outline: none;">
                            {% autoescape off %}
                                {{ proposed_options }}
                            {% endautoescape %}
                        </script>
                    </div>
                    <div id="btns2"></div>
                </div>
                <div style="width: 100%;padding-bottom: 50px;">
                    <div style="width: 90%;height: 40px;line-height: 40px;margin-left: 5%;background-color: #F5F5F5;color: #1E90FF;padding-left: 1%;border: #cccccc solid 1px;border-top: none;border-bottom: none;padding-right: 1%;">
                        上传附件
                        <a href="javascript:;" class="file" style="vertical-align: top;margin-top: 5px;float: right;">
                            上传文件
                            <input type="file" name="party_main_body" id="party_main_body"
                                   onchange="upload_accessory('file1', 'party_main', 'party_main_body', 'db_bh')">
                        </a>
                    </div>
                    <table style="width: 90%;margin-left: 5%;">
                        <thead>
                        <tr>
                            <td style="width: 5%;border: #cccccc solid 1px;text-align: center;height: 35px;line-height: 35px;">
                                序号
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;height: 35px;line-height: 35px;">
                                文件名称
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;height: 35px;line-height: 35px;">
                                文件大小
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;height: 35px;line-height: 35px;">
                                上传时间
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;height: 35px;line-height: 35px;">
                                上传人员
                            </td>
                            <td style="width: 15%;border: #cccccc solid 1px;border-left: none;text-align: center;height: 35px;line-height: 35px;">
                                操作
                            </td>
                        </tr>
                        </thead>
                        <tbody style="overflow: auto;" id="party_main">
                            {% for record in file_list %}
                                <tr>
                                    <td style="width: 5%;border: #cccccc solid 1px;text-align: center;">{{ forloop.counter }}</td>
                                    <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.file_name }}</td>
                                    <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.file_size }}</td>
                                    <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.upload_time }}</td>
                                    <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.uploader }}</td>
                                    <td style="width: 15%;border: #cccccc solid 1px;border-left: none;text-align: center;"><a target='_blank' href="{{ record.file_path }}">查看</a> | <a style="color: red;" href='#' onclick='RemoveTr(this, "party_main", {{ record.id }})' >删除</a></td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div id="staff-select" class="shade" style="z-index: 10100">
        <div id="staff-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 900px;height: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="staff-box"
                     style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        选择人员
                    </div>
                    <span onclick="close_model()"
                          style="float: right;padding-right: 2%;cursor: pointer;line-height: 37px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 460px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 70px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div id="dep" class="navigation navigation_color" onclick="change_navigation(this)">部门</div>
                        <div id="limits" class="navigation" onclick="change_navigation(this)">权限</div>
                        <div id="fun" class="navigation" onclick="change_navigation(this)">职能</div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input id="SearchDep" onkeydown="SearchDepartment()" class="search_input" type="text"
                                   placeholder="搜索" autocomplete="off" style="width: 90%;">
                        </div>
                        <div id="SecondaryNavigation"
                             style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input type="checkbox" id="select-all" onclick="SelectAll(this)">
                            <input id="SearchPeo" onkeydown="SearchProple()" class="search_input" type="text"
                                   placeholder="搜索" autocomplete="off" style="width: 90%;">
                        </div>
                        <div id="ThreeNavigation"
                             style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 410px;height: 100%;display: inline-block;vertical-align: top;overflow: auto">
                        <div id="selected-number"
                             style="width: 100%;height: 40px;text-align: left;font-size: 14px;line-height: 40px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;已选0人
                        </div>
                        <div id="selected-div"
                             style="width: 100%;font-size: 14px;height: 370px;overflow: auto;line-height: 20px;">

                        </div>
                        <div style="width: 100%;font-size: 14px;height: 40px;text-align: center;">
                            <button id="finish_with" onclick="IdentifyPersonnel()"
                                    style="width: 100px;height: 30px;line-height: 25px;text-align: center;letter-spacing: 5px;border-radius: 3px;border: #cfcfcf solid 1px;font-size: 14px;cursor: pointer;margin-top: 10px;">
                                完成
                            </button>
                            <button onclick="close_model()"
                                    style="margin-left: 15px;width: 100px;height: 30px;line-height: 25px;text-align: center;color: #0abb78;letter-spacing: 5px;border-radius: 3px;font-size: 14px;border: #cfcfcf solid 1px;cursor: pointer;margin-top: 10px;">
                                取消
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="selection-office" class="office-shade">
        <div id="office-model">
            <!-- 标题 -->
            <div id="office-title">
                <h5 style="line-height: 40px;width: 15%;margin-left: 1%;display: inline-block;font-size: 14px;">
                    选择科室</h5>
                <span onclick="close_office_models()"
                      style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i
                        class="iconfont icon-quchu"></i></span>
            </div>
            <hr>
            <div style="width: 55%;height: 350px;vertical-align: top;left: 0;display: inline-block;border-right: #cfcfcf solid 1px;">
                <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                    <input id="search_data1" onkeydown="search_dep()" class="search-input" type="text" placeholder="搜索"
                           autocomplete="off">
                </div>
                <div id="processed" style="width: 100%;height: 300px;overflow: auto;">
                    {% for company in company_list %}
                        <div style="width: 100%;height: 30px;line-height: 30px;font-size: 14px;color: #0b0b0b;">
                            <input class="check_box1" id="{{ company.id }}" type="checkbox"
                                   onclick="check_dep_ff('{{ company.name }}', '{{ company.id }}', false)"> {{ company.name }}
                        </div>
                    {% endfor %}
                </div>
            </div>

            <div style="width: 43%;height: 360px;vertical-align: top;left: 0;display: inline-block;">
                <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;font-size: 14px;">
                    已选择科室
                </div>
                <div id="processed_prople" style="width: 100%;height: 265px;overflow: auto;padding-left: 2%;">

                </div>
                <div style="width: 100%;height: 40px;text-align: center;">
                    <button onclick="summit_val()"
                            style="border-radius: 2px;height: 30px;margin-top: 5px;border: #1E90FF solid 1px;background: #1E90FF;color: white;width: 80px;letter-spacing: 4px;font-size: 14px;">
                        提交
                    </button>
                    <button onclick="close_office_models()"
                            style="border-radius: 2px;height: 30px;margin-top: 5px;border: #cfcfcf solid 1px;width: 80px;letter-spacing: 4px;margin-left: 15px;font-size: 14px;">
                        取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div id="del_adjunct"
         style="z-index: 1000;position: fixed;background-color: rgba(36, 36, 36, 0.5);width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;display: none;">
        <div style="top: 50%;left: 50%;width: 400px;height: 150px;background: white;transform:translate(-50%,-50%);border: #dfdfdf solid 1px;position: absolute;border-radius: 4px;">
            <div style="width: 100%;height: 100px;text-align: center;line-height: 100px;">请查看附件，删除无用的附件！</div>
            <hr>
            <div style="width: 100%;height: 50px;text-align: right;padding-right: 5%;">
                <button onclick="del_adjunct_button()"
                        style="width: 50px;height: 30px;line-height: 30px;margin-top: 10px;background: #00a0e9;color: white;border-radius: 4px;border: #00a0e9 solid 1px;">
                    确认
                </button>
            </div>
        </div>
    </div>

    <div id="reviewed" class="shade">
        <div id="new_models" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="box"
                     style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;line-height: 40px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 50%;margin-left: 1%;display: inline-block;">
                        选择审核人
                    </div>
                    <span onclick="close_models()" style="float: right;padding-right: 2%;cursor: pointer;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="width: 100%;border-bottom: #dfdfdf solid 1px;padding-bottom: 20px;">
                    <div style="width: 100%;margin-top: 10px;margin-left: 15px;">
                        <label for="">委员会办公室审核人: </label>
                        <input id="one_step" type="text" style="width: 300px;height: 30px;border: #cfcfcf solid 1px;border-radius: 3px;outline: none;" onclick="model_line_with_parameters(this.id)">
                    </div>

                    <div style="width: 100%;margin-left: 15px;margin-top: 15px;">
                        <label for="" style="letter-spacing: 1.2px;">副&nbsp;&nbsp;&nbsp;主&nbsp;&nbsp;&nbsp;任&nbsp;&nbsp;&nbsp;委&nbsp;&nbsp;&nbsp;员: </label>
                        <input id="two_step" type="text" style="width: 300px;height: 30px;border: #cfcfcf solid 1px;border-radius: 3px;outline: none;" onclick="model_line_with_parameters(this.id)">
                    </div>

                    <div style="width: 100%;margin-top: 20px;margin-left: 15px;">
                        <label for="" style="letter-spacing: 1.2px;">主&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;任&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;委&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;员: </label>
                        <input id="three_step" type="text" style="width: 300px;height: 30px;border: #cfcfcf solid 1px;border-radius: 3px;outline: none;" onclick="model_line_with_parameters(this.id)">
                    </div>
                </div>
                <div style="width: 100%;height: 40px;text-align: right;padding-right: 2%;">
                    <button onclick="process_submission()" style="width: 100px;height: 30px;border: #dfdfdf solid 1px;margin-top: 5px;border-radius: 3px;background: #1E90FF;color: white;margin-right: 15px;">
                        提交
                    </button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript" charset="utf-8" src="../../static/announcements/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../static/announcements/ueditor/1.4.3/ueditor.all.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../static/announcements/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="../../static/public_file/js/DepartmentSelection.js"></script>
    <script type="text/javascript" src="../../static/public_file/js/PersonnelChoosersNew.js" charset="gb2312"></script>
    <script>
        window.onload = function () {
            document.getElementById("loading").style.display = "none";
            document.getElementById("personage").className = "add_class";
            document.getElementById("supervision_inspection_management").className = "add-nav-active";
        };
        const uuid = "{{ obj.fj_number | safe }}"

        var ue = UE.getEditor('editor');

        var ue1 = UE.getEditor('editor1');

        var ue2 = UE.getEditor('editor2');

        var company_list = {{ company_list | safe }};

        function jianshu_show() {
            if (document.getElementById("yt_js").style.display === "none") {
                document.getElementById("yt_js").style.display = "inline-block";
            } else {
                document.getElementById("yt_js").style.display = "none";
            }
        }

        function yiju_show() {
            if (document.getElementById("yt_yj").style.display === "none") {
                document.getElementById("yt_yj").style.display = "inline-block";
            } else {
                document.getElementById("yt_yj").style.display = "none";
            }
        }

        function jiejuefangan_show() {
            if (document.getElementById("jj_fa_yj").style.display === "none") {
                document.getElementById("jj_fa_yj").style.display = "inline-block";
            } else {
                document.getElementById("jj_fa_yj").style.display = "none";
            }
        }

        function summit_val() {
            var processed_prople = document.getElementsByClassName("selected-department");
            if (processed_prople.length === 0) {
                alert("请选择拟稿科室！");
                return false
            }
            var dep_list = [];
            for (var i = 0; i < processed_prople.length; i++) {
                dep_list.push(processed_prople[i].innerText)
            }
            document.getElementById("dang_xieban").innerText = dep_list.join();
            close_office_models();
        }

        function summit_val1() {
            var cleck_box_list1 = document.getElementsByClassName("check_box1");
            var xuanzhong1 = ""
            for (var t = 0; t < cleck_box_list1.length; t++) {
                if (cleck_box_list1[t].checked) {
                    xuanzhong1 = xuanzhong1 + cleck_box_list1[t].id + ", "
                }
            }
            document.getElementById("yb_xieban").innerText = xuanzhong1.slice(0, -2);
        }

        function summit_val2() {
            var cleck_box_list2 = document.getElementsByClassName("check_box2");
            var xuanzhong2 = ""
            for (var t = 0; t < cleck_box_list2.length; t++) {
                if (cleck_box_list2[t].checked) {
                    xuanzhong2 = xuanzhong2 + cleck_box_list2[t].id + ", "
                }
            }
            document.getElementById("lh_xieban").innerText = xuanzhong2.slice(0, -2);
        }

        function search_dep() {
            var company_list = {{ company_list | safe }};
            var search_keyword = document.getElementById("search_data1").value;
            var processed = document.getElementById("processed");
            processed.innerHTML = "";
            for (var h = 0; h < company_list.length; h++) {
                if (company_list[h]["name"].indexOf(search_keyword) !== -1) {
                    console.log(company_list[h]["name"])
                    var div_tag = document.createElement("div");
                    div_tag.className = "div_clase";
                    div_tag.innerHTML = '<input class="check_box1" id="' + company_list[h]["id"] + '" type="checkbox" onclick="check_dep_ff(\'' + company_list[h]["name"] + '\', \'' + company_list[h]["id"] + '\', false)"> ' + company_list[h]["name"];
                    processed.appendChild(div_tag)
                }
            }
        }

        // 上传正文
        function upload_accessory(file_type, tbody_id, accessory_type, bh_id) {
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            var files = document.getElementById(accessory_type).files[0];
            form.append(file_type, files);
            form.append('number', uuid)
            form.append("source", "wyhyt")
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/topics_attachments_upload", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        if (JsonDate["code"] === 400) {
                            alert("请上传xlsx格式文件！")
                        }
                        creat_table(JsonDate, tbody_id);
                        document.getElementById("party_main_body").value = "";
                    }
                }
            };
        }

        // 创建附件列表
        function creat_table(JsonData, tbody_id) {
            var t_table = document.getElementById(tbody_id);
            if (Array.isArray(JsonData["pdf_path"])) {
                for (var i = 0; i < JsonData["pdf_path"].length; i++) {
                    var tr = document.createElement("tr");var td1 = document.createElement("td");var td2 = document.createElement("td");var td3 = document.createElement("td");var td4 = document.createElement("td");var td5 = document.createElement("td");var td6 = document.createElement("td");
                    td1.innerHTML = t_table.children.length + 1;td1.style.textAlign = "center";td1.style.border = "#cccccc solid 1px";td1.style.borderTop = "none";
                    td2.innerHTML = JsonData["file_name"];td2.style.paddingLeft = "1%";td2.style.border = "#cccccc solid 1px";td2.style.borderLeft = "none";td2.style.borderTop = "none";
                    td3.innerHTML = JsonData["file_size"];td3.style.textAlign = "center";td3.style.border = "#cccccc solid 1px";td3.style.borderLeft = "none";td3.style.borderTop = "none";
                    td4.innerHTML = JsonData["upload_time"];td4.style.textAlign = "center";td4.style.border = "#cccccc solid 1px";td4.style.borderLeft = "none";td4.style.borderTop = "none";
                    td5.innerHTML = JsonData["uploader"];td5.style.textAlign = "center";td5.style.border = "#cccccc solid 1px";td5.style.borderLeft = "none";td5.style.borderTop = "none";
                    td6.innerHTML = "<a target='_blank' href='" + JsonData["pdf_path"][i]["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["pdf_path"][i]["id"] + "\")'>删除</a>";
                    td6.style.textAlign = "center";td6.style.border = "#cccccc solid 1px";td6.style.borderLeft = "none";td6.style.borderTop = "none";
                    tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);
                    t_table.appendChild(tr);
                }
                if (JsonData["pdf_path"].length > 1) {
                    document.getElementById("del_adjunct").style.display = 'block';
                }
            } else {
                tr = document.createElement("tr");td1 = document.createElement("td");td2 = document.createElement("td");td3 = document.createElement("td");td4 = document.createElement("td");td5 = document.createElement("td");td6 = document.createElement("td");
                td1.innerHTML = t_table.children.length + 1;td1.style.textAlign = "center";td1.style.border = "#cccccc solid 1px";td1.style.borderTop = "none";
                td2.innerHTML = JsonData["file_name"];td2.style.paddingLeft = "1%";td2.style.border = "#cccccc solid 1px";td2.style.borderLeft = "none";td2.style.borderTop = "none";
                td3.innerHTML = JsonData["file_size"];td3.style.textAlign = "center";td3.style.border = "#cccccc solid 1px";td3.style.borderLeft = "none";td3.style.borderTop = "none";
                td4.innerHTML = JsonData["upload_time"];td4.style.textAlign = "center";td4.style.border = "#cccccc solid 1px";td4.style.borderLeft = "none";td4.style.borderTop = "none";
                td5.innerHTML = JsonData["uploader"];td5.style.textAlign = "center";td5.style.border = "#cccccc solid 1px";td5.style.borderLeft = "none";td5.style.borderTop = "none";
                td6.innerHTML = "<a target='_blank' href='" + JsonData["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["id"] + "\")'>删除</a>";
                td6.style.textAlign = "center";td6.style.border = "#cccccc solid 1px";td6.style.borderLeft = "none";td6.style.borderTop = "none";
                tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);
                t_table.appendChild(tr);
            }
        }

        function RemoveTr(_this, tbody_id, wj_id) {
            var table = document.getElementById(tbody_id);
            var trNode = $(_this).parent().parent();
            trNode.remove();

            for (var i = 0; i < table.children.length; i++) {
                table.children[i].children[0].innerHTML = i + 1;
            }

            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/delete_attachments_view", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id=" + String(wj_id));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        alert("删除成功！")
                    }
                }
            };
        }

        function del_adjunct_button() {
            document.getElementById("del_adjunct").style.display = 'none';
        }

        function SelectReviewer() {
            document.getElementById("reviewed").style.display = "table-row";
        }

        function close_models() {
            document.getElementById("reviewed").style.display = "none";
        }

        let title = document.querySelector("#box");
        let addForm = document.querySelector("#new_models");
        title.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm.offsetLeft;
            let y = e.pageY - addForm.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                addForm.style.left = e.pageX - x + 'px';
                addForm.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function IdentifyPersonnel(obj_id) {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i = 0; i < selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            document.getElementById(obj_id).value = prople_list.join();
            close_model()
        }

        function choose_committee() {
            var committee_dict = {{ committee_dict | safe }};
            var committee = document.getElementById("committee").value;
            var committee_name = document.getElementById("committee_name").innerHTML = "";
            $("#committee_name").append('<option value="0">请选择委员会名称</option>')
            for (var i = 0; i < committee_dict[committee].length; i++) {
                var html_str = `
                    <option value="` + committee_dict[committee][i]["id"] + `">` + committee_dict[committee][i]["name"] + `</option>
                `
                $("#committee_name").append(html_str)
            }
        }

        function get_topic_number() {
            var committee_name = document.getElementById("committee_name").value;
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/get_committee_topics_number", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("committee=" + committee_name);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        document.getElementById("number").innerText = JsonDate["topic_number"];
                    }
                }
            };
        }

        function process_submission() {
            var one_step = document.getElementById("one_step").value;               // 委员会办公室审核人
            var two_step = document.getElementById("two_step").value;               // 副主任委员
            var three_step = document.getElementById("three_step").value;               // 主任委员
            var number = document.getElementById("number").innerText;                               // 编号
            var committee_type = document.getElementById("committee_type").value;                               // 议题类型
            var committee = document.getElementById("committee").value;                               // 委员会级别
            var expert_database = document.getElementById("expert_database").value;                               // 专家库
            var topic_name = document.getElementById("topic_name").innerText;                               // 议题名称
            var committee_name = document.getElementById("committee_name").value;               // 委员会名称
            var dang_xieban = document.getElementById("dang_xieban").innerText;                         // 协办科室
            var note = document.getElementById("note").innerText;                         // 备注
            var topic_ytnr = btoa(encodeURI(UE.getEditor("editor").getContent()));                     // 议题内容
            var topic_ytyj = btoa(encodeURI(UE.getEditor("editor1").getContent()));                            // 议题依据
            var topic_jjfa = btoa(encodeURI(UE.getEditor("editor2").getContent()));                    // 解决方案
            if (!one_step) {
                alert("请选择委员会办公室审核人！");
                return false
            }
            if (!two_step) {
                alert("请选择副主任委员！");
                return false
            }
            if (!three_step) {
                alert("请选择主任委员！");
                return false
            }
            if (committee_type === "0") {
                alert("请选择议题类型！");
                return false
            }
            if (committee === "0") {
                alert("请选择委员会级别！");
                return false
            }
            if (expert_database === "0") {
                alert("请选择专家库！");
                return false
            }
            if (!topic_name) {
                alert("请输入议题名称！");
                return false
            }
            if (committee_name === "0") {
                alert("请选择委员会名称！");
                return false
            }
            if (!topic_ytnr){
                alert("议题内容不能为空");
                return false
            }
            if (!topic_jjfa){
                alert("解决方案不能为空");
                return false
            }
            var form = new FormData();
            form.append("one_step", one_step);
            form.append('two_step', two_step)
            form.append('three_step', three_step)
            form.append("number", number);
            form.append('committee_type', committee_type)
            form.append('committee', committee)
            form.append('expert_database', expert_database)
            form.append('topic_name', topic_name)
            form.append('committee_name', committee_name)
            form.append('dang_xieban', dang_xieban)
            form.append('topic_ytnr', topic_ytnr)
            form.append('topic_ytyj', topic_ytyj)
            form.append('topic_jjfa', topic_jjfa)
            form.append('note', note)
            form.append('id', '{{ obj.id }}')
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/committee_topics_index.html", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("创建成功");
                            window.location = "/supervision-inspection/committee_topics_list.html";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
            };
        }

        function save_data() {
            var committee_type = document.getElementById("committee_type").value;                               // 议题类型
            var committee = document.getElementById("committee").value;                               // 委员会级别
            var expert_database = document.getElementById("expert_database").value;                               // 专家库
            var topic_name = document.getElementById("topic_name").innerText;                               // 议题名称
            var committee_name = document.getElementById("committee_name").value;               // 委员会名称
            var dang_xieban = document.getElementById("dang_xieban").innerText;                         // 协办科室
            var note = document.getElementById("note").innerText;                         // 备注
            var topic_ytnr = btoa(encodeURI(UE.getEditor("editor").getContent()));                     // 议题内容
            var topic_ytyj = btoa(encodeURI(UE.getEditor("editor1").getContent()));                            // 议题依据
            var topic_jjfa = btoa(encodeURI(UE.getEditor("editor2").getContent()));                    // 解决方案

            var form = new FormData();
            form.append('committee_type', committee_type)
            form.append('committee', committee)
            form.append('expert_database', expert_database)
            form.append('topic_name', topic_name)
            form.append('committee_name', committee_name)
            form.append('dang_xieban', dang_xieban)
            form.append('topic_ytnr', topic_ytnr)
            form.append('topic_ytyj', topic_ytyj)
            form.append('topic_jjfa', topic_jjfa)
            form.append('note', note)
            form.append('id', '{{ obj.id }}')
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/committee_topics_draft.html", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("保存成功");
                            window.location = "/supervision-inspection/committee_topics_list.html";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
            };
        }
    </script>
{% endblock %}
